home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 2 / MacMania 2.toast / Demo's / Tools&Utilities / Programming / Tools Plus 2.5 / Tools Plus 2.5 (C⁄C++ & Pascal) / User Manual / 23-Completing Your Application < prev    next >
Encoding:
Text File  |  1994-05-24  |  26.9 KB  |  400 lines  |  [TEXT/ttxt]

  1. 23  Completing Your Application
  2. ```````````````````````````````
  3.  
  4.   This section details the final steps that you must take to produce a stand-alone, double-clickable application.  The requirements for an application using Tools Plus libraries are nearly identical to those of ordinary Macintosh applications, except that the SIZE resource has some very specific needs.  It is assumed that by the time you address these concerns, you have already written and debugged an application within your development environment and that you are ready to make it a stand-alone application.
  5.  
  6.   All the work encompassed in this section requires that you use a resource editor such as Apple’s ResEdit to create and/or modify resources.  The THINK C/C++ and THINK Pascal development environments allow you to use a resource file as part of your project.  That resource file is automatically merged into your compiled code when you build your project.  Therefore we recommend you create and save these resources in a separate resource file and allow your development environment to merge them with your application (instead of manually adding them to your compiled application).
  7.  
  8.   Completing your application involves making some decisions, then creating the appropriate resources.  The table below summarizes the various tasks and their significance to your final application.
  9.  
  10.  
  11. ===============================+========================================
  12. Task (section in this chapter) | Significance to your application
  13. ===============================+========================================
  14. Application Icons              | Defines the icons that are displayed by
  15. File Types, Creators, and the  | the Finder for your application and the
  16.    Application Signature       | files it creates.
  17. Bundle (BNDL resource)         | 
  18. -------------------------------+----------------------------------------
  19. Version (vers resource)        | For displaying a version number in your
  20.                                | application’s “Get Info” box.  An
  21.                                | application description can also be
  22.                                | displayed. (Optional)
  23. -------------------------------+----------------------------------------
  24. mstr resource                  | Remapping of the File menu’s “Quit”
  25.                                | item and the File menu’s “Open…” item
  26.                                | to another menu and/or menu item.
  27.                                |    The “Quit”  command is automatically
  28.                                | invoked when your application is
  29.                                | running and the user selects the
  30.                                | Special menu’s Restart or Shut Down
  31.                                | commands.
  32.                                |    The “Open…” command is automatically
  33.                                | invoked when your application is
  34.                                | running and the user double-clicks
  35.                                | (opens) a document created by your
  36.                                | application.
  37.                                |    If your application does not have
  38.                                | the “Open…” or “Quit” items in a “File”
  39.                                | menu, and your application will [i] run
  40.                                | on Macs with System 5 or 6, or [ii] not
  41.                                | process high-level events, you need to
  42.                                | add mstr resources. (Optional)
  43. -------------------------------+----------------------------------------
  44. SIZE resource                  | Defines your application’s behavior and
  45.                                | memory requirements in a multi-
  46.                                | tasking environment.  Needed for
  47.                                | MultiFinder and System 7.
  48. -------------------------------+----------------------------------------
  49.  
  50.  
  51.  
  52.  
  53. Application’s Icons
  54. ```````````````````
  55.   The Macintosh’s Finder displays an application and its related files as icons.  In order for the Finder to do this, it needs to know what each icon looks like.  Without this information, your application will have the “generic application” icon (diamond with a hand holding a pen) and its related files will have the “generic document” icon (blank page with corner folded down).
  56.  
  57.   At the very least, you will need to create a large (32x32 bit) black and white icon (ICN#) for your application, and one for each type of document it creates.  You should also consider creating equivalent small (16x16 bit) black and white icons (ics#), because the Finder displays these miniatures when a disk’s or folder’s view is set to “small icon,” or when System 7 displays lists with icons.
  58.  
  59.   System 7 can display your application’s icons in color, so you can optionally include color icons as equivalents for the black and white ones.  The icl8 and icl4 icon types are large icons using 8 bits (256 colors) and 4 bits (16 colors) respectively.  Small color icons can also be created as ics8 and ics4 type icons.  Later, the “bundle” describes how to integrate the icon resources into your finished application.
  60.  
  61.  
  62.  
  63.  
  64.  
  65. Icon Family
  66. ```````````
  67.   When a specific icon ID number is shared by two or more icon types, those related icons are called an “icon family.”  The icon family with an ID of 128 is usually the icon that depicts your application.  Your application’s document icons would likely be numbered 129 and up.  When you create icons, remember to use ID numbers 128 or higher.  The rest are reserved numbers.
  68.  
  69. Note: When creating icl8 and ics8 icons with ResEdit, you have a choice
  70.       of two color palettes: “Apple icon colors” or “Standard 256
  71.       colors.”  Use the Apple icon colors, since they will guarantee
  72.       that your icon can be selected (darkened) properly.
  73.  
  74.  
  75.  
  76.  
  77.  
  78. File Types, Creators, and the Application Signature
  79. ```````````````````````````````````````````````````
  80.   On the Macintosh, all files (including application, desk accessories, documents, etc.) have a file type and a creator code.  Both of these items are always four characters long, allowing any visible or invisible characters and spaces.  The file type tells the Macintosh what the file contains.  Your application will always have a file type of ‘APPL.’  You can define your own file types for the documents created by your application if they don’t fit into any of the existing general types as follows:
  81.  
  82.     APPL    Launchable application
  83.     DFIL    File for sorting DAs
  84.     DRVR    Driver
  85.     FFIL    File for sorting fonts
  86.     INIT    System extension
  87.     PICT    QuickDraw picture
  88.     PRER    Printer driver
  89.     RDEV    Chooser extension
  90.     TEXT    Stream of ASCII characters
  91.     adev    Network extension
  92.     appe    Background-only application
  93.     cdev    Control panel
  94.     edtp    Edition for sharing graphics
  95.     edts    Edition for sharing sound
  96.     edtt    Edition for sharing text
  97.     ffil    Font
  98.     ifil    Script system resources
  99.     kfil    Keyboard layout
  100.     pref    Preferences file
  101.     qery    Query document (databases)
  102.     scri    System extension for scripting
  103.     sfil    Sound
  104.     tfil    TrueType font
  105.     ttro    TeachText read-only file
  106.     zsys    A system file
  107.  
  108.   Later, the “bundle” describes how to integrate file type(s) into your finished application.
  109.  
  110.  
  111.  
  112.  
  113.  
  114. Signature (the Creator code)
  115. ````````````````````````````
  116.   Each application must have a unique, four character signature.  A signature is often called a creator code because it answers the question “who created me” for every document on a Macintosh (an application is considered to be its own creator).  Your application’s signature will be used as the creator code for all the documents it creates.
  117.  
  118.   The Finder makes an association between each application and its related documents by using the application’s signature.  When a document is opened by the Finder, it knows which application created the file and automatically launches that application.
  119.  
  120.   Notice that some file types can be opened by several applications.  If you double-click a ‘TEXT’ file, it will be opened by the application that launched it (because the Finder recognizes the creator for the file is identical to the parent application’s signature).  However, just about any word processor can open a ‘TEXT’.
  121.  
  122.   In THINK Pascal, you set your application’s type and creator by using the Project menu’s “Set project Type” command.  Later, the “bundle” describes how to integrate the signature into your finished application.
  123.  
  124.  
  125. Note: Apple reserves the use of all file types and signatures (creator
  126.       codes) whose names contain only lowercase letters, and those that
  127.       contain only non-alphabetic characters.  Your file types and
  128.       signatures must contain at least one uppercase letter.  Since the
  129.       system software never displays the file type or signature to
  130.       users, these codes don’t have to be meaningful to anyone but you.
  131.          All file types and signatures must be registered with Apple to
  132.       guarantee uniqueness and prevent conflicts between applications.
  133.  
  134. Warning: When deciding upon a signature for your application, be careful
  135.          to avoid signatures that are identical to any existing resource
  136.          type, such as ‘ICON’ or ‘STR ’.  An owner resource must be
  137.          created with a type that matches your application’s signature,
  138.          and if it coincides with existing resources types, conflicts
  139.          may arise.  For a comprehensive list of resource codes, please
  140.          refer to the ResEdit Reference manual, or contact Apple.
  141.  
  142.  
  143.  
  144.  
  145.  
  146. Bundle
  147. ``````
  148.   The BNDL resource, which is simply called the “bundle,” is used to “bundle up” several related resources that are needed to define the association between your application, its documents, and the icons displayed by the Finder.  If you use ResEdit to create the BNDL resource, you will be presented with a template that lets you create and maintain the BNDL resource.
  149.  
  150.   Enter the four character signature you have selected for your application.
  151.  
  152.   Next, use the Resource menu’s “Create New File Type” command to create a new line.  Enter the file type.  Note that the first line should have a type of ‘APPL’ (application).  Double-click its “Finder Icons” section and you will be presented with a list of icons that you created earlier in the “Application Icons” section of this chapter.  Select the icon you want to use to represent the specified file type.  Repeat this for each file type that is supported by your application.
  153.  
  154.   The last thing you must do to complete the bundle is to set the “bundle bit.”  The bundle bit tells the Finder that your application has a bundle present.  In THINK Pascal, you set the bundle bit by using the Project menu’s “Set project Type” command, then building your application.  THINK C/C++ sets the bundle bit automatically.
  155.  
  156.   When creating the BNDL resource, ResEdit automatically creates several other supporting resources.  One FREF resource (Finder REFerence) is created for each file type.  An “Owner Resource” is also created (ID=0).  Its resource type matches your application’s signature.  The owner resource is essentially a string resource that lets you enter a comment that is displayed as version information in the Finder’s “Get Info” box (providing you don’t create ‘vers’ resources).
  157.  
  158.  
  159. Note: If you change your application’s icons, you will have to rebuild
  160.       the desk top file to force the Finder to use your new icons.  To
  161.       rebuild the desk top, restart your Macintosh while holding the
  162.       option and command keys down, and continue to hold them until you
  163.       see a dialog that asks you if you want to rebuild your desk top.
  164.       Click the OK button to start rebuilding.
  165.          A similar problem sometimes occurs when an application is
  166.       copied to a disk using an installer or decompression program.
  167.       These kinds of programs may not have the intelligence to update
  168.       the desk top file like the Macintosh’s Finder does.
  169.  
  170.  
  171.  
  172.  
  173.  
  174. Version
  175. ```````
  176.   Your application can display some descriptive information in the Finder’s “Get Info” box by having ‘vers’ resources.  The two vers resources you can include in your applications are:
  177.  
  178.    ID=1  Application version number (i.e. 2.5, ©1994 - Water’s Edge
  179.          Software)
  180.  
  181.    ID=2  Application info displayed beneath the file name  (i.e, Tools
  182.          Plus Library (1 of 3) )
  183.  
  184. By using vers resources, any file can bear version information, including documents created by your application.
  185.  
  186.  
  187.  
  188.  
  189.  
  190. mstr Resources
  191. ``````````````
  192.   This section describes how System 5 and 6’s MultiFinder and System 7 automatically interact with your application’s menus if your application does not support high-level events (also called Apple Events).  You should set the appropriate bit in your application’s ‘SIZE’ resource to indicate if it supports Apple Events or not.
  193.  
  194.   Both MultiFinder (running under System 5 or 6) and System 7 can automatically interact with your application through its menus.  If your application is running while the user double-clicks (or select-opens) one of your application’s documents from the Finder, the affected document is automatically opened by your application.  Also, if the user selects the Special menu’s Restart or Shut Down command while your application is running, it is instructed to quit.
  195.  
  196.   In both these cases, the system simulates the selection of a menu item.  Typically applications have a File menu with an item named “Open…” (including the ellipsis, the Option-; character), and the last item named “Quit”.  In the case of opening a document, PollSystem returns a doMenu event to your application indicating that the File menu’s “Open…” command was selected, in which case your application would do whatever is appropriate, like display an SFGetFile dialog to let the user choose which file to open.  The system fools your application into thinking that the double-clicked file was selected from an SFGetFile dialog (which is not actually displayed).  When the user selects Restart or Shut Down, PollSystem returns a doMenu event to your application indicating that the File menu’s “Quit” command was selected, in which case your application would do whatever is appropriate, such as asking if open documents should be saved before quitting.
  197.  
  198.   If your application does not [1] open files by using the File menu’s “Open…” command, or [2] quit by using the File menu’s “Quit” command, these functions can be remapped to other menu items by including ‘mstr’ resources in your application.  Each mstr resource is a Pascal string (byte-0 is the length byte) that tells the Macintosh which menu and menu item to use in place of the standard ones:
  199.  
  200.    mstr ID=100   Name of the menu containing the equivalent of the
  201.                  “Quit” command
  202.  
  203.    mstr ID=101   Name of the menu item that is the equivalent of the
  204.                  “Quit” command
  205.  
  206.    mstr ID=102   Name of the menu containing the equivalent of the
  207.                  “Open…” command
  208.  
  209.    mstr ID=103   Name of the menu item that is the equivalent of the
  210.                  “Open…” command
  211.  
  212.  
  213.  
  214.  
  215.  
  216. SIZE Resource
  217. `````````````
  218.   If your application is going to run under MultiFinder or System 7, it needs a SIZE resource.  ResEdit has a resource template for the SIZE resource, which lets you set various values in the resource to specify how your application behaves in a multi-tasking environment.
  219.  
  220.   You will create a single resource with an ID of -1, but be aware that the Macintosh may clone (make a duplicate with a possible minor variation) your SIZE resource in your stand-alone application under certain conditions.  This is described later.
  221.  
  222.   The SIZE resource is comprised of sixteen bits that can be set to a value of 0 or 1, and two long integers.  Tools Plus requires that some of these items be set to a specific value while others depend upon how you want your application to behave.  The table below details the SIZE resource.
  223.  
  224.  
  225.         Compulsory Setting \   / Recommended Setting
  226.                             \ /
  227. SIZE Template’s Field Name | | | Comments
  228. ===========================+=+=+========================================
  229. Save screen (obsolete)     |0|0| (obsolete)
  230. ---------------------------+-+-+----------------------------------------
  231. Accept suspend events      |1|1| 0 = doSuspend and doResume events are
  232.                            | | |     not reported to your application.
  233.                            | | | 1 = Your application receives a
  234.                            | | |     doSuspend event prior to being
  235.                            | | |     suspended, and a doResume event
  236.                            | | |     immediately after being activated.
  237. ---------------------------+-+-+----------------------------------------
  238.                            |0|0| (obsolete)
  239. ---------------------------+-+-+----------------------------------------
  240. Can background             | |1| 0 = When your application is suspended,
  241.                            | | |     it receives no processing time
  242.                            | | | 1 = When your application is suspended,
  243.                            | | |     it receives processing time in the
  244.                            | | |     way of doNothing events.
  245.                            | | | If “Accept suspend events” is set to 0,
  246.                            | | | this item must be set to 1.
  247. ---------------------------+-+-+----------------------------------------
  248. Does activate on FG switch |1|1| 0 = The Macintosh’s operating system
  249.                            | | |     takes care of activating and
  250.                            | | |     deactivating a window when the
  251.                            | | |     application is suspended or
  252.                            | | |     resumed.
  253.                            | | | 1 = Your application takes care of
  254.                            | | |     activating or deactivating its
  255.                            | | |     windows in response to a doSuspend
  256.                            | | |     or doResume event (automatic in
  257.                            | | |     Tools Plus).
  258.                            | | | This item must have the same setting as
  259.                            | | | “Accept suspend events.”
  260. ---------------------------+-+-+----------------------------------------
  261. Only background            |0|0| 0 = Your application is a regular
  262.                            | | |     application.
  263.                            | | | 1 = Your application runs only in the
  264.                            | | |     background.  Usually, this is
  265.                            | | |     because it doesn’t have a user
  266.                            | | |     interface and cannot run in the
  267.                            | | |     foreground.
  268. ---------------------------+-+-+----------------------------------------
  269. Get front clicks           | |0| 0 = Your application does not receive
  270.                            | | |     the mouse-down used to activate it
  271.                            | | |     after being suspended.  Most
  272.                            | | |     applications work this way.
  273.                            | | | 1 = The mouse-down that activates your
  274.                            | | |     application is applied to your
  275.                            | | |     application.  This may mean that a
  276.                            | | |     button is selected, drawing begins,
  277.                            | | |     or an insertion point is set.  The
  278.                            | | |     Finder works in this manner.
  279. ---------------------------+-+-+----------------------------------------
  280. Accept app died events     | |0| 0 = ApplicationDied events are not
  281. (debuggers)                | | |     generated
  282.                            | | | 1 = Your application is notified (via
  283.                            | | |     an ApplicationDied event) when an
  284.                            | | |     application or process launched by
  285.                            | | |     your application has terminated or
  286.                            | | |     has crashed.  Read about System 7’s
  287.                            | | |     Process Manager for more details.
  288. ---------------------------+-+-+----------------------------------------
  289. 32 bit compatible          | |0| 0 = Your application is not 32-bit
  290.                            | | |     compatible
  291.                            | | | 1 = Your application can be run with
  292.                            | | |     the 32-bit Memory Manager.
  293.                            | | | Don’t set this flag to 1 unless you
  294.                            | | | have thoroughly tested your application
  295.                            | | | on a 32-bit system, such as on a
  296.                            | | | Macintosh IIci running System 7 in
  297.                            | | | 32-bit mode.
  298. ---------------------------+-+-+----------------------------------------
  299. High level event aware     | |0| 0 = No high-level events are received
  300.                            | | |     or sent by your application
  301.                            | | | 1 = Your application can receive and
  302.                            | | |     send high-level events (System 7)
  303.                            | | | If this item is set to 0, MultiFinder
  304.                            | | | and System 7 will automatically
  305.                            | | | interact with your application’s menus.
  306.                            | | | See the “Menus” chapter for details.
  307. ---------------------------+-+-+----------------------------------------
  308. Local and remote high      | |0| 0 = Your application cannot be
  309.   evel events              | | |     accessed by applications running on
  310.                            | | |     other computers on a network.
  311.                            | | | 1 = Your application is accessible by
  312.                            | | |     applications running on other
  313.                            | | |     computers on a network, and it can
  314.                            | | |     receive high-level events across a
  315.                            | | |     network (System 7).
  316. ---------------------------+-+-+----------------------------------------
  317. Stationery aware           | |0| 0 = If the user opens a stationary
  318.                            | | |     document (System 7), the Finder
  319.                            | | |     makes a copy of the file and asks
  320.                            | | |     the user to name the copy.
  321.                            | | | 1 = Your application knows how to work
  322.                            | | |     with stationery documents
  323.                            | | |     (System 7)
  324. ---------------------------+-+-+----------------------------------------
  325. Use text edit services     | |0| 0 = Your application does not use
  326.                            | | |     inline TextEdit services
  327.                            | | | 1 = Your application uses inline
  328.                            | | |     TextEdit services (System 7).
  329.                            | | | Tools Plus’s editing fields don’t use
  330.                            | | | inline TextEdit services.  Set this
  331.                            | | | item to 1 only if you have designed
  332.                            | | | your own editing fields that use these
  333.                            | | | services.
  334. ---------------------------+-+-+----------------------------------------
  335. Reserved bit               |0|0| (reserved for future use)
  336. ---------------------------+-+-+----------------------------------------
  337. Reserved bit               |0|0| (reserved for future use)
  338. ---------------------------+-+-+----------------------------------------
  339. Reserved bit               |0|0| (reserved for future use)
  340. ---------------------------+-+-+----------------------------------------
  341. Size                       | | | The memory size at which your
  342.                            | | | application can run most efficiently.
  343.                            | | | When your application is launched, the
  344.                            | | | Operating System tries to secure this
  345.                            | | | amount of memory.
  346. ---------------------------+-+-+----------------------------------------
  347. Min size                   | | | The memory limit below which your
  348.                            | | | application will not run.
  349. ---------------------------+-+-+----------------------------------------
  350.  
  351.  
  352.  
  353.  
  354.  
  355. Cloned SIZE resources
  356. `````````````````````
  357.   Although you need to create only one SIZE resource (ID=-1), the Macintosh may make clones of it when the user makes changes in the Finder’s “Get Info” box.  When the user makes changes in the “Get Info” box, the Macintosh clones (makes a copy of the SIZE resource with ID=-1) and lets the user makes changes to the “Size” and “Min size” fields of the clone.  You only need to be concerned with this if you want to preset your application’s memory requirements to something other than the recommended limits defined by your original SIZE resource.
  358.  
  359.   The table below describes the contents of the “Size” and “Min size” fields for the original SIZE resource, as well as any clones that may be created by the Macintosh.
  360.  
  361.  
  362. ===========+====+=========+================+============================
  363. System File|SIZE| Field’s | Title in       |
  364.   Version  | ID |  Name   | “Get Info” box | Contents
  365. ===========+====+=========+================+============================
  366. 5 to 7.0.x | -1 |Size     |Application     | Memory required for optimum
  367.            |    |         |memory size     | performance
  368.            |    +---------+----------------+----------------------------
  369.            |    |Min size |Suggested memory| Memory limit below which
  370.            |    |         |size            | your application won’t run
  371.            +----+---------+----------------+----------------------------
  372.            | 0  |Size     |Application     | User’s setting
  373.            |    |         |memory size     |
  374.            |    +---------+----------------+----------------------------
  375.            |    |Min size |Suggested memory| Memory limit below which
  376.            |    |         |size            | your application won’t run
  377.            |    |         |                | (same as ID=-1)
  378. -----------+----+---------+----------------+----------------------------
  379. 7.1 or     | -1 |Size     |Suggested size  | Memory required for optimum
  380. higher     |    |         |                | performance
  381.            |    +---------+----------------+----------------------------
  382.            |    |Min size |(not displayed) | Memory limit below which
  383.            |    |         |                | your application won’t run
  384.            +----+---------+----------------+----------------------------
  385.            | 0  |Size     |Preferred size  | User’s preferred memory
  386.            |    |         |                | allowance
  387.            |    +---------+----------------+----------------------------
  388.            |    |Min size |(not displayed) | Memory limit below which
  389.            |    |         |                | your application won’t run
  390.            |    |         |                | (same as ID=-1)
  391.            +----+---------+----------------+----------------------------
  392.            | 1  |Size     |(not displayed) | User’s preferred memory
  393.            |    |         |                | allowance
  394.            |    |         |                | (same as ID=0)
  395.            |    +---------+----------------+----------------------------
  396.            |    |Min size |Minimum size    | User’s minimum memory
  397.            |    |         |                | allowance below which the
  398.            |    |         |                | application won’t run.
  399. -----------+----+---------+----------------+----------------------------
  400.